import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class WeiBoUserCountReduce extends Reducer<Text, IntWritable, Text, IntWritable> {
    @Override
    protected void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
        // 统计微博用户性别比例
        int cnt = 0;
        for (IntWritable value : values) {
            int i = value.get();
            cnt += i;
        }
        // 将结果输出到HDFS
        context.write(key, new IntWritable(cnt));
    }
}
